# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>

pkgname=pari
pkgver=2.15.4
pkgrel=1
pkgdesc='Computer algebra system designed for fast computations in number theory'
url='https://pari.math.u-bordeaux.fr/'
license=(GPL)
arch=(loong64 x86_64)
depends=(gmp libx11)
makedepends=(perl texlive-latex chrpath)
optdepends=('perl: gphelp, tex2mail'
            'pari-elldata: J. Cremona elliptic curve database'
            'pari-galdata: to compute Galois groups in degrees 8 through 11'
            'pari-seadata: needed by ellap for large primes'
            'pari-galpol: GALPOL database of polynomials defining Galois extensions of the rationals')
checkdepends=(pari-elldata pari-galdata pari-seadata pari-galpol)
source=(https://pari.math.u-bordeaux.fr/pub/pari/unix/$pkgname-$pkgver.tar.gz{,.asc})
sha256sums=('c3545bfee0c6dfb40b77fb4bbabaf999d82e60069b9f6d28bcb6cf004c8c5c0f'
            'SKIP')
validpgpkeys=('42028EA404A2E9D80AC453148F0E7C2B4522E387')

prepare() {  
  cd $pkgname-$pkgver
  sed -e 's|DLLDFLAGS  = \$DLLDFLAGS|DLLDFLAGS  = $DLLDFLAGS $LDFLAGS|' -i config/Makefile.SH # Honor system LDFLAGS
}

build() {
  cd $pkgname-$pkgver

  ./Configure \
    --prefix=/usr \
    --with-readline \
    --mt=pthread \
    --with-gmp
  make all
#  make -C Olinux-x86_64 gp-sta
}

check() {
  cd $pkgname-$pkgver
  make test-all
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
#  make DESTDIR="$pkgdir" -C Olinux-x86_64 install-bin-sta
  ln -sf gp.1.gz "$pkgdir"/usr/share/man/man1/pari.1
  chrpath -d "$pkgdir"/usr/bin/gp-*
}
